#ifndef ODN_SINGLETON_H
#define ODN_SINGLETON_H

namespace ouden {

//TODO: Consider fancifying this class
template <class T>
class CSingleton
{
	public:
		virtual ~CSingleton() 		{}
		
		//TODO: Delete !!!!!!!!!!!!!!!!!!!!!!
		
		//static __stdcall T* getInstance() 		{ static T inst; return &inst; }
		static T* getInstance()
		{
			
			if (!m_pInstance)
				m_pInstance = new T();
			
			return m_pInstance;
			
		}
		
	protected:
		
		CSingleton() 		{}
		
		static T* m_pInstance;
		
	private:
		
};

//template<class T>
//T* CSingleton<T>::m_pInstance = 0;

/*
template <class T>
class CSingleton
{
	
public:
	
	T* getInstance()
	{
		
		if (!m_pInstance)
			m_pInstance = new T;
		return m_pInstance;
		
	}
	
	class CAutoDelete {
	public:
		~CAutoDelete() 		{ delete pObject; }
		void setObjectToDelete(void* pObject)
	private:
		void* pObject;
		
	};
	
private:
	
	static T* m_pInstance;
	
};*/

} //namespace ouden


#endif //ODN_SINGLETON_H
